<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                <LINK rel="stylesheet" type="text/css" href="commun_styles.css"/>
            <title>Equipement</title>
        </head>
        <body>
            <h:form id="formequipement">
                <a4j:include viewId="entete.jsp"/>
                <a4j:include viewId="menu.jsp"/>
                <h:inputHidden value="#{EquipementBean.init}"/>
                <rich:spacer height="50px"/>
                <center>
                    <rich:tabPanel style="width:500px;">
                        <rich:tab label="Equipement">
                            <h:panelGrid width="450px" columns="1">
                            <h:outputText id="infomsg" value="#{EquipementBean.message}" />
                                <rich:panel header="Liste Equipements" id="tablepanel">
                                    <rich:dataTable
                                    onRowMouseOver="this.style.backgroundColor='#B5CEFD'" binding="#{EquipementBean.dataTable}"
                                        onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
                                        onRowClick="this.style.backgroundColor='#F1F1F1'"
                                        rows="8" width="100%" id="tbl" value="#{EquipementBean.equip_list}" var="equip">
                                    <rich:column>
                                        <f:facet name="header">
                                            <h:outputText value="Libelle"/>
                                        </f:facet>
                                        <h:outputText value="#{equip.eqLib}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">
                                            <h:outputText value="Etat"/>
                                        </f:facet>
                                        <h:outputText value="#{equip.eqEtat}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">
                                            <h:outputText value="Service"/>
                                        </f:facet>
                                        <h:outputText value="#{equip.service.servLib}"/>
                                    </rich:column>
                                    <rich:column style="text-align:center" width="70px">
                                        <f:facet name="header">
                                            <h:outputText value="Modifier"/>
                                        </f:facet>
                                        <a4j:commandLink action="#{EquipementBean.modifierLigne}" reRender="infomsg,tablepanel,panelinfo,crud_panel" >
                                            <h:graphicImage style="border:0" url="/images/Modify.gif" />
                                        </a4j:commandLink>
                                    </rich:column>
                                    <rich:column style="text-align:center">
                                        <f:facet name="header">
                                            <h:outputText value="Supprimer"/>
                                        </f:facet>
                                        <a4j:commandLink action="#{EquipementBean.supprimer}" ajaxSingle="true" reRender="infomsg,tablepanel,panelinfo,crud_panel">
                                            <h:graphicImage style="border:0" url="/images/Delete.gif"/>
                                        </a4j:commandLink>
                                    </rich:column>
                                    <f:facet name="footer">
                                        <rich:datascroller/>
                                    </f:facet>
                                    </rich:dataTable>
                                </rich:panel>
                                <rich:panel id="panelinfo" header="Information generales">
                                    <h:panelGrid columns="2" width="350">
                                        <h:outputText value="Libelle : "/>
                                        <h:inputText id="libequip" value="#{EquipementBean.equip.eqLib}" disabled="#{EquipementBean.etat}"
                                        size="25" maxlength="30"></h:inputText>
                                        <h:outputText value="Description : "/>
                                        <h:inputTextarea id="descequip" value="#{EquipementBean.equip.eqDescr}" disabled="#{EquipementBean.etat}"
                                        rows="3"/>
                                        <h:outputText value="Etat : "/>
                                        <h:selectOneRadio id="etatequip" disabled="#{EquipementBean.etat}" value="#{EquipementBean.equip.eqEtat}">
                                            <f:selectItem itemLabel="Fonctionnel" itemValue="Fonctionnel"/>
                                            <f:selectItem itemLabel="En panne" itemValue="En Panne"/>
                                        </h:selectOneRadio>
                                        <h:outputText value="Service : " />
                                        <rich:comboBox id="servequip" defaultLabel="Entrez une valeur" disabled="#{EquipementBean.etat}"
                                        value="#{EquipementBean.current_service}" suggestionValues="#{EquipementBean.service_list}" required="true"></rich:comboBox>
                                    </h:panelGrid>
                                </rich:panel>
                            </h:panelGrid>
                            <h:panelGrid id="crud_panel" columns="5">
                                <a4j:commandButton id="nouvequip" value="Nouveau" style="width:85px" ajaxSingle="true"
                                disabled="#{EquipementBean.invetat}" action="#{EquipementBean.viderChamps}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                                <a4j:commandButton id="modifequip" value="Modifier" style="width:85px"ajaxSingle="true"
                                disabled="#{EquipementBean.invetat}" action="#{EquipementBean.modifier}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                                <a4j:commandButton id="supppequip" value="Supprimer" style="width:85px" ajaxSingle="true"
                                disabled="#{EquipementBean.invetat}" action="#{EquipementBean.supprimer}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                                <a4j:commandButton id="validequip" value="Valider" style="width:85px" 
                                disabled="#{EquipementBean.etat}" action="#{EquipementBean.create}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                                <a4j:commandButton id="annulequip" value="Annuler" style="width:85px" ajaxSingle="true"
                                disabled="#{EquipementBean.etat}" action="#{EquipementBean.annuler}" reRender="infomsg,tablepanel,panelinfo,crud_panel"/>
                            </h:panelGrid>
                        </rich:tab>
                    </rich:tabPanel>
                </center>
            </h:form>
        </body>
    </html>
</f:view>